package com.fqgj.sentry.controller.rm.request;

import com.fqgj.sentry.common.exception.BizException;
import com.fqgj.sentry.common.exception.enums.ErrorCodeEnums;
import com.fqgj.sentry.common.request.ParamsObject;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by ykpbean kangping.ying@yuntu-inc.com
 *
 * @description
 * @create 2017-10-13 下午2:21
 */


public class TodayQueryTermsRequest extends ParamsObject {

    /**
     * 开始时间
     */
    private String startDate;
    /**
     * 结束时间
     */
    private String endDate;
    /**
     * 事件类型
     */
    private Long eventId;
    /**
     * 执行者类型
     */
    private String executorIds;
    /**
     * 为null 是全部
     */
    private String version;
    /**
     * 执行者类型
     */
    private String executorType;

    /**
     * 渠道来源
     */
    private String source;
    /**
     * 订单类型 1.新增 2. 复借
     */
    private Integer borrowType;

    public String getVersion() {
        return version;
    }

    public TodayQueryTermsRequest setVersion(String version) {
        this.version = version;
        return this;
    }

    public String getExecutorType() {
        return executorType;
    }

    public TodayQueryTermsRequest setExecutorType(String executorType) {
        this.executorType = executorType;
        return this;
    }

    @Override
    public void validate() {
        if (eventId == null || StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)) {
            throw new BizException(ErrorCodeEnums.param_valid_error);
        }
        if (StringUtils.isNotBlank(source) &&
                source.contains(",")) {
            String[] sources = source.split(",");
            source = "";
            for (String temp : sources) {
                source = source + "," + temp;
            }
        }
        if (StringUtils.isNotBlank(version)) {
            version = version.replace("v", "");
        }
    }

    public String getStartDate() {
        return startDate;
    }

    public TodayQueryTermsRequest setStartDate(String startDate) {
        this.startDate = startDate;
        return this;
    }

    public String getEndDate() {
        return endDate;
    }

    public TodayQueryTermsRequest setEndDate(String endDate) {
        this.endDate = endDate;
        return this;
    }

    public Long getEventId() {
        return eventId;
    }

    public TodayQueryTermsRequest setEventId(Long eventId) {
        this.eventId = eventId;
        return this;
    }

    public String getExecutorIds() {
        return executorIds;
    }

    public TodayQueryTermsRequest setExecutorIds(String executorIds) {
        this.executorIds = executorIds;
        return this;
    }

    public String getSource() {
        return source;
    }

    public TodayQueryTermsRequest setSource(String source) {
        this.source = source;
        return this;
    }

    public Integer getBorrowType() {
        return borrowType;
    }

    public TodayQueryTermsRequest setBorrowType(Integer borrowType) {
        this.borrowType = borrowType;
        return this;
    }
}
